package com.example.miniot.controller;

import com.example.miniot.config.MinioConfig;
import io.minio.errors.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;

/**
 * Created by SunYuechao on 2022/3/14 上午10:55
 */
@RestController
@RequestMapping("/api/minio/oss")
public class MinioController {
    @Autowired
    MinioConfig minioHelper;

    @PostMapping("/upload")
    //@ApiOperation(value = "图片上传管理")
    public Object upload (@RequestParam("file") MultipartFile multipartFile) throws InvalidKeyException, InvalidEndpointException, InvalidPortException, ErrorResponseException, IllegalArgumentException, InsufficientDataException, InternalException, InvalidBucketNameException, InvalidResponseException, NoSuchAlgorithmException, XmlParserException, RegionConflictException, IOException {
        return  this.minioHelper.putObject(multipartFile);
    }
}
